package com.xiaoqian.partyembassy.view;

import android.app.Dialog;
import android.content.Context;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import com.xiaoqian.partyembassy.R;


/**
 * 项目名称: i尚家
 * 包: com.dnake.ifationhome.view
 * 类名称: DialogWifiConnectPair
 * 类描述: 显示设备版本号
 * 创建人:黄飞
 * 创建时间: 2017/12/4
 * 修改人:
 * 修改时间:
 * 修改备注:
 * 版本: v1.0
 */
public class DialogDeviceInfoVs implements View.OnClickListener{

    // 上下文
    private Context mContext;
    // 布局加载器
    private LayoutInflater inflater;
    // 布局
    private View layout;
    public Dialog build;
    // 是
    private TextView dialog_context_tv;
    // 取消
    private TextView mCancleTv;
    // 标题
    //内容
    private TextView dialog_title_tip;//标题
    private ImageButton dialog_title_closed;//关闭
    private ImageButton dialog_state_img;//图状态
    private Button dialog_back_btn;
    private Button dialog_again_btn;

    public DialogDeviceInfoVs(Context mContext) {
        this.mContext = mContext;
        initView();
        initDialog();
    }

    /**
     * 初始化布局
     */
    private void initView(){
        inflater = (LayoutInflater) mContext .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        layout = inflater.inflate(R.layout.dialog_device_info_vs, null);
        dialog_context_tv = layout.findViewById(R.id.dialog_context_tv);
        dialog_title_tip = layout.findViewById(R.id.dialog_title_tip);
        dialog_title_closed = layout.findViewById(R.id.dialog_title_closed);
        dialog_state_img = layout.findViewById(R.id.dialog_state_img);
        dialog_back_btn = layout.findViewById(R.id.dialog_back_btn);
        dialog_again_btn = layout.findViewById(R.id.dialog_again_btn);

    }

    /**
     * 初始化弹出框
     */
    @SuppressWarnings("deprecation")
    private void initDialog(){
        build = new Dialog(mContext, R.style.custom_dialog);
        // 设置布局
        build.setContentView(layout);
        Window window = build.getWindow();
        // 居中显示
        window.setGravity(Gravity.CENTER);
        WindowManager manager = (WindowManager) mContext
                .getSystemService(Context.WINDOW_SERVICE);
        Display display = manager.getDefaultDisplay();
        WindowManager.LayoutParams params = window.getAttributes();
        params.width = display.getWidth();
        window.setAttributes(params);
        // 设置窗口弹出动画
       // window.setWindowAnimations(R.style.dialogWindowAnim);
      //  window.setBackgroundDrawableResource(android.R.color.transparent);
        build.setCanceledOnTouchOutside(false);
    }


//    public void setVsInfo(String devModleHw, String devModleSw){
//        if(null != dev_devmodlehw){
//            dev_devmodlehw.setText(devModleSw);
//        }
//        if(null != dev_devmodlesw){
//            dev_devmodlesw.setText(devModleHw);
//        }
//    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){



        }
    }

    /**
     * 取消弹出框
     */
    public void dismiss() {
        if(null != build && build.isShowing()){
            build.dismiss();
        }
    }
    /**
     * 显示弹出框
     */
    public void show(){
        if(null != build && !build.isShowing()){
            build.show();
        }
    }

}
